package com.wnxy.eleba.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.eleba.entity.Sj;
import com.wnxy.eleba.mapper.SjMapper;
import com.wnxy.eleba.service.SjService_zhuying;
import com.wnxy.eleba.vo.SjQueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class SjServiceImpl_zhuying implements SjService_zhuying {
    private SjMapper sjMapper;

    @Autowired
    public void setSjMapper(SjMapper sjMapper) {
        this.sjMapper = sjMapper;
    }

    @Override
    public Sj findSjById(Integer sjId) {
        return sjMapper.selectByPrimaryKey(sjId);
    }

    @Override
    public List<Sj> findAll() {
        List<Sj> sjList = sjMapper.showAll();

        return sjList;
    }

    @Override
    public PageInfo<Sj> listSjPageByCondition(SjQueryParam sjQueryParam) {
        PageHelper.startPage(sjQueryParam.getCurrentPage(),sjQueryParam.getPageSize());
        List<Sj> sjList = sjMapper.selectSjByCondition(sjQueryParam);
        PageInfo<Sj> pageInfo = new PageInfo<>(sjList);
        return pageInfo;
    }

    @Override
    public boolean saveSj(Sj sj) {
        return sjMapper.insert(sj)!=0;
    }

    @Override
    public boolean updateSj(Sj sj) {
        return sjMapper.updateByPrimaryKey(sj)!=0;
    }

    @Override
    public boolean deleteSj(Integer[] ids) {
        return sjMapper.del(Arrays.asList(ids))!=0;
    }

    @Override
    public boolean delSj(Integer id) {
        return sjMapper.deleteByPrimaryKey(id)!=0;
    }

    @Override
    public List<String> listsjType() {
        return sjMapper.listAllSjType();
    }
}
